package com.example.aopdemo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-26
 * Time: 20:10
 */
public class JDKInvocation implements InvocationHandler {
    //目标对象/被代理对象
    private Object target;

    public JDKInvocation(HouseSubject target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始代理");
        Object result = method.invoke(target,args);
        System.out.println("结束代理");
        return result;
    }
}
